﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RoleList.aspx.cs" Inherits="XYTXL.View.RoleList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>角色列表</title>
    <link href="/View/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="/View/CSS/Admin.css" />
    <link rel="stylesheet" type="text/css" href="/View/CSS/Role.css" />
    <link rel="stylesheet" type="text/css" href="/View/JS/smartMenu/css/smartMenu.css" />
    <script src="/View/JS/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="/View/JS/smartMenu/js/jqueryMenu.js"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            //创建新角色
            $("#divaddrole").click(function (e) {
                var obj = $("#MangerRole").html();
                parent.MyDialog.viewhtml(obj, '添加角色', '', '', function (layero, index) {
                    $(layero).find(".btconfirm").click(function () {
                        var rolename = $(layero).find(".tbRoleName").val();
                        var roledec = $(layero).find(".tbRoleDec").val();
                        var isuse = $(layero).find(".ckIsUse").attr("checked") ? "Y" : "N";
                        $.ajax({
                            type: "GET",
                            url: "AdminHandle.ashx",
                            dataType: "html",
                            data: { "Action": "addRole", "rolename": rolename, "roledec": roledec, "isuse": isuse },
                            success: function (msg) {
                                parent.MyDialog.tips("添加成功")
                                location.reload();
                            }
                        });
                    });
                });
            });
            //按字母查找
            $("#divsort span").click(function (e) {
                var text = $(this).text();
                $("#divrole .topic-item").hide();
                if (text === "ALL") {
                    $("#divrole .topic-item").show();
                }
                else if (text === "系统角色") {
                    $("#divrole  div[issys='Y']").show();
                }
                else if (text === "不可用角色") {
                    $("#divrole  div[isuse='N']").show();
                }
                else {
                    $("#divrole  div[serzm='" + text + "']").show();
                }
                $("#divsort span").css({ "color": "#4987C9" });
                $(this).css({ "color": "#ff7e00" });

            });


            $(".role").each(function () {
                if ($(this).attr('issys') == 'Y') {
                    $(this).prepend('<img src="/View/images/tag.png"  style="top: 0; right: 0; overflow: hidden; width: 20px; height: 20px; float: right;"   title="系统角色,不能删除"/>');
                }
            })


            //角色单击事件
            var bodyMenuData = [
                [{
                    text: "删除角色.",
                    func: function () {
                        if ($(this).attr('issys') != "Y") {
                            var rolecode = $(this).attr('rolecode');
                            parent.MyDialog.confirm('你确定要删除该角色吗', function () {
                                $.ajax({
                                    type: "GET",
                                    url: "AdminHandle.ashx",
                                    dataType: "html",
                                    data: { "Action": "delRole", "delCode": rolecode },
                                    success: function (msg) {
                                        parent.MyDialog.tips("删除成功")
                                        location.reload();

                                    }
                                });
                            });
                        } else {
                            parent.MyDialog.warning("您不能删除系统角色")
                        }


                    }
                }, {
                    text: "修改角色.",
                    func: function () {
                            var obj = $("#MangerRole").html();
                            var roledom = $(this);
                            var rolecode = $(this).attr('rolecode');
                            parent.MyDialog.viewhtml(obj, '修改角色', '', '', function (layero, index) {
                                //初始化修改窗口
                                $(layero).find(".tbRoleName").val(roledom.attr('rolename'));
                                $(layero).find(".tbRoleDec").val(roledom.attr('roledec'));
                                $(layero).find(".ckIsUse").attr("checked", roledom.attr('isuse') == "Y" ? true : false);
                                $(layero).find(".btconfirm").click(function () {
                                    var rolename = $(layero).find(".tbRoleName").val();
                                    var roledec = $(layero).find(".tbRoleDec").val();
                                    var isuse = $(layero).find(".ckIsUse").attr("checked") ? "Y" : "N";
                                    $.ajax({
                                        type: "GET",
                                        url: "AdminHandle.ashx",
                                        dataType: "html",
                                        data: { "Action": "updateRole", "rolecode": rolecode, "rolename": rolename, "roledec": roledec, "isuse": isuse },
                                        success: function (msg) {
                                            parent.MyDialog.tips("修改成功")
                                            location.reload();
                                        }
                                    });
                                });
                            });
                    }
                }],
                [{
                    text: "管理角色人员.",
                    func: function () {
                        var rolecode = $(this).attr('rolecode');
                        var pageurl = '/View/Base/AassignUser.aspx?RoleCode=' + rolecode;
                        parent.MyDialog.viewform(pageurl, '管理角色人员', 650, 600);
                    }
                }, {
                    text: "管理角色权限.",
                    func: function () {
                        var rolecode = $(this).attr('rolecode');
                        var pageurl = '/View/Base/AassignMenu.aspx?RoleCode=' + rolecode;
                        parent.MyDialog.viewform(pageurl, '管理角色权限', 650, 600);
                    }
                }]
            ];
            $("#divrole .topic-item").smartMenu(bodyMenuData, {
                name: "menurole",
                afterShow: function () {
                    if ($(this).attr('issys') == "Y") {
                        $("a", ".smart_menu_ul").eq(0).css({ "color": "darkgray" })
                    } else {
                        $("a", ".smart_menu_ul").eq(0).css({ "color": "#000" })
                    }

                }
            });
            //角色单击事件

        })</script>
</head>
<body>
    <form id="form1" runat="server">
        <div  class=" container-fluid" style="height:200px;">
        <div class="topic-item" style="float: none; margin-bottom: 20px;" id="divaddrole">
            <div class="topic-img">
                <img src="/View/images/ic_popup_new.png" style="width: 64px; height: 64px;">
            </div>
            <div class="topic-title">
                <span style="color: red;">创建新角色</span>
            </div>
        </div>
        <hr style="width: 97%;margin:5px" />
        <div style="width: 97%; padding-left: 20px;" id="divsort">
            <%=strSearchZM %>
        </div>
        <hr style="width: 97%;margin:5px"  />
        <div style="overflow: auto; height:250px; position: absolute; width: 98%" id="divrole">
            <asp:Repeater ID="RptRole" runat="server">
                <ItemTemplate>
                    <div class="topic-item role" serzm="<%#Eval("SerZM") %>" rolename="<%#Eval("RoleName") %>"
                        rolecode="<%#Eval("RoleCode") %>" issys="<%#Eval("isSysRole") %>" isuse="<%#Eval("IsUse") %>"
                        roledec="<%#Eval("RoleDec") %>">

                        <div class="topic-img">
                            <img src="/View/images/ic_menu_group.png" style="width: 64px; height: 64px;">
                        </div>
                        <div class="topic-title">
                            <span style="color: #4987C9">
                                <%#DataBinder.Eval(Container.DataItem, "RoleName")%></span>
                        </div>

                    </div>
                </ItemTemplate>
            </asp:Repeater>
        </div>
        <div id="MangerRole" style="display: none">


            <div class="formbody">

                <div class="formtitle"><span>添加角色</span></div>

                <ul class="forminfo">
                    <li>
                        <label>角色名称</label>
                        <asp:TextBox ID="tbRoleName" class="dfinput tbRoleName" runat="server" Text="" /><i>不能为空</i></li>
                    <li>
                        <label>角色描述</label><asp:TextBox ID="tbRoleDec" class="dfinput tbRoleDec" runat="server" Text="" /><i></i></li>
                    <li  style="display:none">
                        <label>是否审核</label><cite><input id="ckIsUse" type="checkbox" class="ckIsUse" checked="checked" />是</cite></li>

                    <li>
                        <label>&nbsp;</label><input type="button" class="bluebuttoncss btconfirm" value="确认保存" style="height: 30px; width: 100px" /></li>
                </ul>


            </div>
        </div>
        </div>
    </form>
</body>
</html>
